package com.xdpdp.smile.hystrix.show.command;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;

public class CommandDemo extends HystrixCommand<String> {

    private String name;

    public CommandDemo(String name) {
        super(Setter
                .withGroupKey(HystrixCommandGroupKey.Factory.asKey("CommandHelloWord")));
        this.name = name;
    }

    /**
     * 单次请求调用的业务方法
     *
     * @return
     * @throws Exception
     */
    @Override
    protected String run() throws Exception {
        String result = "CommandHelloWord name :" + name;

        Thread.sleep(800l);

        System.out.println(result + ",currentThread-" + Thread.currentThread().getName());
        return result;
    }
}
